<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

// 工具--清理--用户登录日志
use App\Console\Tools\Clean\UserLoginLog as ToolsCleanUserLoginLog;

class Kernel extends ConsoleKernel
{

    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        // 工具--清理--用户登录日志
        ToolsCleanUserLoginLog::class,
    ];

    /**
     * Define the application's command schedule.
     *
     * @param \Illuminate\Console\Scheduling\Schedule $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        /**
         * ************************ 清理日志 *************************
         */
        // 清理活动日志，保留最近 60 天记录【每天 0 点执行一次任务】
        $schedule->command('activitylog:clean --days=60')->daily()->runInBackground();
        // 清理登录日志，保留最近 60 天记录【每天 0 点执行一次任务】
        $schedule->command('tools:clean:user-login-log --days=60')->daily()->runInBackground();
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        // $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }
}
